﻿/******************************************************************************
 *
 * @copyright:          Copyright 2011 UniSky Ltd.
 * @file:
 * @author:              kenping.liu
 * @creation:
 * @description:
 *
 * @modifications
 * date         user                description
 *
 *
 * @more-details
 *
 *****************************************************************************/
#ifndef _UNISKY_LOGGER_H_
#define _UNISKY_LOGGER_H_

#include "u_sys.h"

U_NAMESPACE_BEGIN(u)

extern const char LEVEL_NAMES[8][6];
typedef enum
{
    L_ALL   = 0,
    L_TRACE = 1,
    L_DEBUG = 2,
    L_INFO  = 3,
    L_WARN  = 4,
    L_ERROR = 5,
    L_FATAL = 6,
    L_OFF   = 7
} Level;

class Log
{
public:
	Log();
	virtual ~Log();

    static void trace(const TCHAR* fmt, ...);
    static void debug(const TCHAR* fmt, ...);
    static void info(const TCHAR* fmt, ...);
    static void warn(const TCHAR* fmt, ...);
    static void error(const TCHAR* fmt, ...);
    static void fatal(const TCHAR* fmt, ...);

    static void write(const char* file, const char* fmt, ...);

private:
    void log(UINT _Level, const TCHAR* _Fmt,  va_list _Args);

private:
    u::sys::Lock     _lock;
    char             _msg[40960];
    char             _dbg_msg[51200];
    char			_module[1024];
};

U_NAMESPACE_END(u)

#endif
